package com.tian.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tian.dao.EmpMapper;
import com.tian.entity.Echarts01;
import com.tian.entity.Emp;
import com.tian.entity.User;
import com.tian.service.EmpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: Tian
 * @version: 1.0
 * @since: 1.0
 * @date: 2024/3/8/20:52
 */
@Service
public class EmpServiceImpl implements EmpService {
    @Resource
    private EmpMapper empMapper;
    @Override
    public int insertEmp(Emp emp) {
        int insert = empMapper.insert(emp);
        return insert;

    }

    @Override
    public int updateEmp(Emp emp) {
        int count = empMapper.updateByPrimaryKey(emp);
        return count;
    }

    @Override
    public Emp selectEmp(Long id) {
        Emp emp = empMapper.selectByPrimaryKey(id);
        return emp;

    }

    @Override
    public PageInfo<Emp> selectAll(Integer current, Integer pageSize) {
        PageHelper.startPage(current,pageSize);
        List<Emp> emps= empMapper.selectAll(current,pageSize);
        PageInfo<Emp> pageInfo=new PageInfo<>(emps);
        return pageInfo;
    }


    @Override
    public List<Echarts01> selectCount() {
        return empMapper.searchCount();
    }
}
